package com.hyk.commonLib.common.utils;

import android.text.TextUtils;

import com.hyk.commonLib.common.utils.cache.MultiCache;

/**
 * Created by 贺玉琨 on 2020/4/24.
 */
public class AvoidDuplicateCallUtils {
    private static final MultiCache cache = new MultiCache();

    public static boolean canCall(String key) {
        return cache.get(key) == null;
    }

    public static void call(String key, Runnable runnable, int interval) {
        if (TextUtils.isEmpty(key)) return;
        if (!canCall(key)) return;
        cache.save(key, key, interval);
        runnable.run();
    }
}
